#ifndef __FND_BASE_ERROR_H__
#define __FND_BASE_ERROR_H__

//#include "SpiFoundation/RoomFW/RoomFW/IPayload.h"	// Note:  This must be #included *before* export.hpp or you'll get a compilation error.
#include "RoomFW/IPayload.h"   // @az

#include <boost/serialization/export.hpp>		// BOOST_CLASS_EXPORT_GUID:  See http://www.boost.org/doc/libs/1_39_0/libs/serialization/doc/serialization.html#export
#include <boost/serialization/shared_ptr.hpp>	// To avoid: error C2039: 'serialize' : is not a member of 'boost::shared_ptr<T>'

#include "IError.h"

namespace ErrorHandling {

//
// Class:	    Error
//
// Description:	Error base class. Derived classes should add pertinant error
//              information, which is accessed via double dispatch with the
//              error handler.
//
class BaseError : public IError
{
	//
	// The following overridden functions from base class IError
	// must be overridden in derived classes
	//
public:
	BaseError( 
		ErrorId err_id = EID_NULL, 
		ErrorSeverity sev = ESEVunknown,
		std::string description = "",
		IErrorSP cause = IErrorSP());

	virtual ~BaseError();
	BaseError(const BaseError& b);

	virtual void raise();
	virtual IErrorSP clone() const throw();

	virtual const char* getName() const throw();

	//
	// the following methods overridden from base class IError
	// do not need to be overridden in derived classes
	//
	virtual std::string            toString() const throw();
	virtual const char*            what() const throw();
	virtual const ErrorId          getId() const throw();
	virtual const ErrorSeverity    getSeverity() const throw();
	virtual void                   setSeverity( ErrorSeverity sev ) throw();
	virtual const ErrorTimeStamp   getTimeStamp() const throw();
	virtual const IErrorSP         getCause() const throw();
	virtual void                   setCause( IErrorSP cause ) throw();
	virtual std::string			   getDescription() const throw();
	virtual void				   setSourceObjectName(std::string sourceObjectName) throw();
	virtual std::string			   getSourceObjectName() const throw();

	//
	// Override in derived classes with additional shared pointer attributes.
	//
	virtual bool                   isSafe() const throw(); 

	friend class boost::serialization::access;
    template<class Archive>
	void serialize(Archive & ar, const unsigned int file_version)
	{
		boost::serialization::base_object<IError>(*this);

		ar & what_;
		ar & id_;
		ar & severity_;
		ar & timestamp_;
		ar & cause_;
		ar & description_;
		ar & sourceObjectName_;
	}
	
	
private:
	BaseError& operator=(const BaseError& b);	// Private and unimplemented.  Don't use.

	mutable std::string what_; // Just used to allow safe return of const char*
	ErrorId           id_;
	ErrorSeverity     severity_;
	ErrorTimeStamp    timestamp_;
	IErrorSP          cause_;
	std::string		  description_;
	std::string		  sourceObjectName_;
};
typedef boost::shared_ptr<BaseError> BaseErrorSP;

} // end namespace ErrorHandling



#endif // __FND_BASE_ERROR_H__
